﻿using NHibernate;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WebSite.Core;
using WebSite.Data.NH.Infrastructure;
using WebSite.Model;

namespace WebSite.Data.NH.Repositories
{
    public interface ICompanyRepository : IRepository<CompanyInfo>
    {
        CompanyInfo GetCompany(int id);
        bool UpdateCompany(CompanyInfo ci);
    }
    public class CompanyRepository : NhRepositoryBase<CompanyInfo>, ICompanyRepository
    {
        private readonly IUnitOfWork uow;

        public CompanyRepository(ISession session, IUnitOfWork uow)
            : base(session)
        {
            this.uow = uow;
        }

        public CompanyInfo GetCompany(int id)
        {
           var result = GetById(id);
           return result;
        }

        public bool UpdateCompany(CompanyInfo ci)
        {
            var result = Update(ci);
            uow.Commit();
            return result;
        }
    }
}
